--[[ 
弹头夺宝相关数据 
]]

local M = class("DtdbDB")


--[[
    服务端数据最终奖励结构
    key   格子
    value icon标示id
]]

function M:ctor()
    self:init()
    Game:registerLogoutReset(self, handler(self, self.init))
end

function M:init()
    self._data = {}
    self._redPoint 		= false
	self._playerIng 	= false   	 	--播放中
	self._winLists      = {}            --中奖的线
	self._isAutoRun     = false         --是否自动循环
    self._itemInfo      = {}            --格子数据
    self._winCount      = 0             --赢的钱
    self._speed         = 10            --转速
    self._isBigBet      = false         -- 是否大奖
    self._monsterData   = {}            -- 狩猎年兽数据
    
    self._lineList = self:getRuleForConfig()
end

function M:getRuleForConfig()
    if not LineRulesConfig then return end
    local cfg = {}
    for k,v in ipairs(LineRulesConfig) do
        cfg[k] = v.universal
    end
    -- table.sort(cfg,function(a,b)
        -- if type(a) == "number" and type(b) == "number" then
                        -- return a < b
                    -- else
                        -- return tostring(a) < tostring(b)
                    -- end
    -- end)
    return cfg
end


function M:setData(data)
    self._data = data
end

function M:getData()
    return self._data
end

--[[
赢钱多少
]]
function M:setWinCount(count)
    self._winCount = count
end
function M:getWinCount()
    return self._winCount
end

--[[
9条线规则
]]
function M:getLineRule()
	return self._lineList
end

--[[
每条格子上面的数据
]]
function M:setLineData(data)
    self._itemInfo = data
end
function M:getLineData()
	return self._itemInfo 
end


--[[
最大倍率
]]
function M:getBigBet()
    return self._isBigBet
end

function M:setBigBet(bet)
    self._isBigBet = bet
end

--[[
自动循环
]]
function M:setAutoRun(isAuto)
	self._isAutoRun = isAuto
    if self._isAutoRun then
        self:setSpeed(10)
    else
        self:setSpeed(10)  --20
    end
end
function M:getAutoRun()
	return self._isAutoRun
end

--[[
转速设置
]]
function M:setSpeed(speed)
    self._speed = speed
end

function M:getSpeed()
    return self._speed
end

----------------------------------
-- 红点
function M:setRedPoint(rp)
    if type(rp) == "boolean" then
        self._redPoint = rp
    else
        self._redPoint = false
    end
    Game:dispatchCustomEvent(GEvent("GAME_RED_POINT_EVENT"), {key="Dtdb", show=self._redPoint})
end

function M:getRedPoint()
    return self._redPoint
end

function M:onExit()
	self:init()
end

----------------------------------
-- 狩猎年兽
function M:setMonsterData(data)
    self._monsterData = data
end

function M:getMonsterData(key)
    if key then
        return self._monsterData[key]
    end
    return self._monsterData
end

----------------------------------
-- 单机数据模拟
function M:testDataMonitor()
    
end

return M:new()
